<template>
	<view>
		<loading :show="loading_show"></loading>
		<customHead
			title="公告通知"
			isShowBackArrow
			:titlePaddingLeft="30"
			color="#000"
			:placeholder="true"
			navi_background="#fff"
		>
		</customHead>
		<view class="content">
			<view class="notice_list" v-if="item.showHide == 0" style="" v-for="item in noticeList"  @click="gopath(item)">
				<view class="notice_text">
					<view class="notice_title">
						{{item.title}}
					</view>
					<view class="notice_content">
						<!-- {{handleContent(item.content)}} -->
						{{item.extJson}}
					</view>
					<view class="createTime">
						{{item.createTime}}  
					</view>
				</view>
				<view class="image_box">
					<image :src="item.activityImgUrl" mode="aspectFill"></image>
				</view>
			</view>
			<view class="emptyGoods" v-if="!noticeList.length">
				<u-empty
					text="暂无公告记录"
					mode="data"
					icon="http://cdn.uviewui.com/uview/empty/data.png"
				>
				</u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	import {searchPlugsNoticeList} from '@/tools/request/api.js'
	export default {
		data() {
			return {
				noticeList:[],
				loading_show: false
			}
		},
		onShow() {
			this.getNoticeList()
		},
		computed: {
			handleContent () {
				return function (content) {
					let str = content;
					if (!str.length) return;
					str = str.split('>')[1];
					str = str.split('<')[0];
					return str;
				}
			}
		},
		methods: {
			// 获取通知信息
			getNoticeList () {
				let data = {
					page: 1,
					size: 100,
					businessId: this.businessId,
					userServiceToken: this.userServiceToken
				}
				this.loading_show = true;
				searchPlugsNoticeList(data).then((res) => {
					this.loading_show = false;
					if (res.code != 200) return uni.$showMsg();
					let list = res.body.list;
					let str = list.filter(item => item.type == 'home_one');
					this.noticeList = str;
				})
			},
			gopath(item){
				uni.navigateTo({
					url:`/subpack_home/noticeList/noticeDetail?info=${encodeURIComponent(JSON.stringify(item))}`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		
		.notice_list{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 20rpx;
			background-color: #fff;
			padding: 20rpx;
			font-size: 26rpx;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			border-bottom: 1rpx solid #e8e8e8;
			
			.notice_text{
				width:  450rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				
				.notice_title{
					font-size: 38rpx;
					font-weight: bold;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				.notice_content{
					width: 100%;
					padding-top: 20rpx;
					padding-bottom: 30rpx;
					color: #878787;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
				.createTime{
					font-size: 24rpx;
					color: #9a9a9a;
				}
			}
			.image_box{
				width: 170rpx;
				height: 170rpx;
				border-radius: 15rpx;
				
				image{
					width: 170rpx;
					height: 170rpx;
					border-radius: 15rpx;
				}
			}
		}
		.emptyGoods{
			
			.button_box{
				margin-top: 30rpx;
				
				.button{
					width: 280rpx;
					height: 74rpx;
					border-radius: 37rpx;
					// background: linear-gradient(to right, #00e297, #00c885);
					color: #fff;	
					font-size: 30rpx;
				}
			}
		}
	}
</style>
